import Vue from 'vue';
import dayjs from 'dayjs'
let vm = new Vue();

// 测试过滤器
export function toUpperCase(arg) {
	return arg && arg.toUpperCase();
}

export function toFixed(num, decimal) {
	if (typeof num !== 'number') return 'need a number'
	return num.toFixed(decimal || 2)
}

export function toFixed2(num) {
	if (typeof num !== 'number') return 'need a number'
	return num.toFixed(2)
}

export function slice(arg, start, end) {
	if (!(typeof arg === 'string' || Array.isArray(arg))) return 'need a string or array'
	return arg.slice(start, end)
}

export function dateFormat(date, method, arg) {
	if (!date) return ''
	return dayjs(date)[method](arg)
}